How to Insert record of a table in History table by stored procedure before update that record
Insert a record of UserDetails table in its UserHistory table by using store procedure before the update that record in UserDetails in SQL server.
Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I completed MCA with 76% form Veer Bahadur Singh Purvanchal University Jaunpur.
SWE @ MindStick | Software Engineer | Web Developer | .Net Developer | Web Developer | Backend Engineer | .NET Core Developer
Ashutosh Kumar Verma
14-Oct-2021Stored Procedure for Insert Record in TableHistory Table before update that Record in TableDetails table in SQL Server :
Suppose I have create two tables one is ‘Users’ table and other is ‘UserHistory ‘ table. Users table stores record of all Users and UserHistory table maintain the record of Users when any User update his record. Here if a User update his record from ‘ Users’ table then before update that particular record will stored in ‘ UserHistory’ table then record is successfully updated from ‘ Users’ table.
Example:
Lets create two table in SQL server Users and UserHistory.
I have insert values in above table like this-
Here I have create UserHistory table,
I have create a Stored Procedure for maintain history of Users.
Here execute the above procedure for update the record from Users table.
Show the Users table record is Updated where Email= ravi@gmail.com
And check the Userhistory table also
The above table ‘UserHistory’ contains the old record of ‘Users’ table that are Updated.